<layout name="layout"/>
<include file="Public:angular"/>
<script style="javascript">

App.controller("Appctrl",["$scope","$http",function($scope,$http){

	$scope.refund_amount="{$order_amount}";
	$scope.order_id="{$order_id}";
	
	//订单历史
	$scope.showhistory=function(url){
		$http.get(url)
		.success(function(response){
			//console.log(response);
			$scope.order_history=response;
			UIkit.modal("#myModal").show();
		}).error(function(response){
			UIkit.modal.alert(response);
		})		
	}
	//物流
	$scope.showdelivery=function(url){
		$http.get(url)
		.success(function(response){
			//console.log(response);
			$scope.order_delivery=response;
			UIkit.modal("#myModal1").show();
		}).error(function(response){
			UIkit.modal.alert(response);
		})		
	}
	

}]);

function toRisk(){
	UIkit.modal.prompt("风险原因：", "", function(input){
		if(input=="")
			return;
		location.href="__CONTROLLER__/flagRisk/oid/{$order_id}/desc/"+input;
	})	
}
</script>

<div ng-controller="Appctrl">
<div  class="uk-button-group">
	<a href="__CONTROLLER__/index" class="uk-button uk-button-default">{$Think.lang.back}</a>

	<a href="__CONTROLLER__/processOrder/oid/{$order_id}/order_status/6" class="uk-button">处理为失败</a>
	<a href="__CONTROLLER__/processOrder/oid/{$order_id}/order_status/5" class="uk-button">取消交易</a>
	<a href="__CONTROLLER__/processOrder/oid/{$order_id}/order_status/2"class="uk-button">处理为成功</a>
	
	<a href="__CONTROLLER__/processOrder/oid/{$order_id}/order_status/3" class="uk-button">处理为预授权</a>
	<a href="__CONTROLLER__/processOrder/oid/{$order_id}/order_status/4" class="uk-button">处理为捕捉</a>

		<button type="button" class="uk-button" data-uk-modal="{target:'#pendingrefundModal',center:true}">申请退款</button>
	<a href="__CONTROLLER__/processOrder/oid/{$order_id}/order_status/8" class="uk-button">平台退款</a>
	<a target=_blank href="{:U('Home/Autohandle/autorefund',array('order_id'=>$order_id))}" class="uk-button">接口退款</a>
	<button type="button" data-uk-modal="{target:'#cbModal',center:true}" class="uk-button uk-button-danger">拒付</button>
</div>

<div class="uk-overflow-container">
<form class="uk-form" method="post" action="__CONTROLLER__/updateHandle">
<input type="hidden" name="order_id" value="{$order_id}"/>
<div class="uk-alert">支付信息</div>	
<table class="uk-table">

<tr><td width=280>#</td><td>
{$order_id}
<notempty name="order_rebill_id">
	<span class="uk-text-warning">&nbsp;&nbsp;周期订单：{$order_rebill_id}</span>
</notempty>	
&nbsp;&nbsp;
<eq name="order_isrisk" value="0">
<button type="button" class="uk-button uk-button-danger" onclick="toRisk()">标记为风险订单</button>	
<else/>
<font color=red>风险订单：{$order_risk_desc}</font>
<a href="__CONTROLLER__/cancelRisk/oid/{$order_id}" class="uk-button">取消标记</a>
</eq>


</td></tr>
<tr><td>ips#</td><td>
<input type="text" name="ips_id" value="{$ips_id}"/>
</td></tr>
<tr><td>商户#</td><td>

<input type="text" name="mh_oid" value="{$mh_oid}"/>
</td></tr>

<tr><td>订单金额</td><td>
{$order_amount}{$order_currency}
</td></tr>
<tr><td>订单时间</td><td>
{$order_time}
</td></tr>
<tr><td>订单状态</td><td>
{$order_status|order_status=true}
&nbsp;&nbsp;	<button type="button" class="uk-button" ng-click="showhistory('__CONTROLLER__/orderhistory_qry/order_id/{$order_id}')" >{$Think.lang.order_history}</button>
	<button type="button" class="uk-button" ng-click="showdelivery('__CONTROLLER__/delivery_qry/order_id/{$order_id}')">物流信息</button>
</td></tr>
<tr><td>{$Think.lang.process_mode}</td><td>
<select name="process_mode" >
<option value="1" <eq name="process_mode" value="1">selected</eq> >sales</option>
<option value="0" <eq name="process_mode" value="0">selected</eq> >authorize</option>
</select>
</td></tr>
<tr><td>商户ID</td><td>
<a href="" onclick='openwin("__MODULE__/Merchant/details/{$order_mid}")'>{$order_mid}</a>
</td></tr>

<tr><td>网站ID</td><td>
<a href=""  onclick='openwin("__MODULE__/Site/details/{$order_siteid}")'>{$order_siteid}</a>
</td></tr>
<tr><td>通道</td><td>
<a href=""  onclick='openwin("__MODULE__/Channels/details/{$order_channel}")'>{$order_channel}</a>
</td></tr>

<tr><td>汇率(=1{$web_config.web_currency})</td><td>
{$order_roe}
</td></tr>
<tr class="uk-alert uk-alert-danger"><td>{$web_config.web_currency}金额</td><td>
<input type="text" name="base_amount" value="{$base_amount}"/>
</td></tr>
<tr><td>通道金额</td><td>
{$gateway_amount}{$gateway_currency}
</td></tr>
<tr><td>通道汇率(=1{$web_config.web_currency})</td><td>
{$gateway_roe}
</td></tr>
<tr><td>汇率差</td><td>
{$gateway_roe_tpl}
</td></tr>

</table>
<div class="uk-alert">账单信息</div>
<table class="uk-table">
<tr><td width=280>信用卡类型</td><td>
{$card_type} &nbsp;
<eq name="cc_cardid|isBlacklist" value="1">
<i class="uk-icon-exclamation-circle"></i>
<else/>
<a href="__CONTROLLER__/inputBlacklist/oid/{$order_id}/type/CreditCard" class="uk-button">将卡列入黑名单</a>
</eq>

</td></tr>	
<tr><td>账单邮箱</td><td>

{$bill_email} &nbsp;
<eq name="bill_email|isBlacklist" value="1">
<i class="uk-icon-exclamation-circle"></i>
<else/>
<a href="__CONTROLLER__/inputBlacklist/oid/{$order_id}/type/Email" class="uk-button">邮箱列入黑名单</button>
</eq>
</td></tr>
<tr><td>账单电话 </td><td>
{$bill_phone} &nbsp;
<eq name="bill_phone|isBlacklist" value="1">
<i class="uk-icon-exclamation-circle"></i>
<else/>
<a href="__CONTROLLER__/inputBlacklist/oid/{$order_id}/type/Phone" class="uk-button">电话列入黑名单</button>
</eq>
</td></tr>
<tr><td>账单国家</td><td>
{$bill_country}
</td></tr>
<tr><td>账单州</td><td>
{$bill_state}
</td></tr>
<tr><td>账单城市</td><td>
{$bill_city}
</td></tr>
<tr><td>账单地址</td><td>
{$bill_street}
</td></tr>
<tr><td>账单邮编</td><td>
{$bill_zip}
</td></tr>
<tr><td>账单名</td><td>
{$bill_firstname}
</td></tr>
<tr><td>账单姓</td><td>
{$bill_lastname}
</td></tr>
<tr><td>来源网址URL</td><td>
{$order_source_url}
</td></tr>
<tr><td>来源IP</td><td>
[{$order_source_ip} &nbsp;{$order_source_ip|getLocationFromIp}&nbsp;]
<eq name="order_source_ip|isBlacklist" value="1">
<i class="uk-icon-exclamation-circle"></i>
<else/>
<a href="__CONTROLLER__/inputBlacklist/oid/{$order_id}/type/IP" class="uk-button">IP列入黑名单</button>
</eq>
</td></tr>
<tr><td>同步通知URL</td><td>
{$order_syn_url}
</td></tr>
<tr><td>异步通知URL</td><td>

<input type="text" name="order_asyn_url" value="{$order_asyn_url}"/>
</td></tr>

<tr><td>账单名</td><td>

<input type="text" name="order_bill_desc" value="{$order_bill_desc}"/>
</td></tr>
</table>
<div class="uk-alert">费率信息</div>
<table class="uk-table">
<tr><td  width=280>保证金费率</td><td>
{$order_rolling_rate}
</td></tr>	
<tr><td>固定交易费</td><td>
{$order_fixedfee}
</td></tr>
<tr><td>交易费率</td><td>
{$order_process_rate}
</td></tr>
<tr><td>退款费</td><td>
{$order_refund_fee}
</td></tr>
<tr><td>失败费</td><td>
{$order_declined_fee}
</td></tr>
<tr><td>拒付费</td><td>
{$order_cb_fee}
</td></tr>
<tr><td>是否通知到</td><td>
<select name="order_asyn_status" >
<option value="1" <eq name="order_asyn_status" value="1">selected</eq> >是</option>
<option value="0" <eq name="order_asyn_status" value="0">selected</eq> >否</option>
</select>
</td></tr>
<tr><td>通知次数</td><td>
<input type="text" name="order_asyn_count" value="{$order_asyn_count}"/>
</td></tr>
<tr><td>--</td><td>
<button class="uk-button uk-button-danger">{$Think.lang.save}</button>
</td></tr>
</table>
</form>
</div>


<!-- Modal -->
<div class="uk-modal" id="myModal">
<div class="uk-modal-dialog uk-modal-dialog-large"> <a class="uk-modal-close uk-close"></a>
<div class="uk-modal-header">{$Think.lang.order_history}</div>

<table class="uk-table">
<tr><td width=120>{$Think.lang.add_time}</td>
<td width=120>记账金额({$web_config.web_currency})</td><td>原始金额({$order_currency})</td><td>通道金额({$gateway_currency})</td><td width=120>订单状态</td><td>备注</td>
</tr>
<tr ng-repeat="item in order_history"><td>{{item.oh_time}}</td>
<td>{{item.oh_amount}}</td>
<td>{{item.oh_origin_amount}}</td>
<td>{{item.oh_gateway_amount}}</td>
<td>{{item.oh_status}}</td><td>{{item.oh_remark}}</td>
</tr>
</table>

</div>
</div>

<!-- Modal -->
<div class="uk-modal" id="myModal1">
<div class="uk-modal-dialog"> <a class="uk-modal-close uk-close"></a>
<div class="uk-modal-header">{$Think.lang.tracking}</div>

<table class="uk-table">
<tr><td>物流公司</td>
<td>查询URL</td><td>物流单号</td>
</tr>
<tr ng-repeat="item in order_delivery"><td>{{item.tk_company}}</td>
<td>{{item.tk_url}}</td><td>{{item.dv_number}}</td>
</tr>
</table>
</div>
</div>

<!-- Modal 申请退款 -->
<div class="uk-modal" id="pendingrefundModal">
    <form id="validate_form" action="__CONTROLLER__/processOrder" class="uk-form" method="get" >
	<input type="hidden" name="oid" value="{$order_id}"/>
	<input type="hidden" name="order_status" value="7"/>
	<div class="uk-modal-dialog"> <a class="uk-modal-close uk-close"></a>
        <div class="uk-modal-header">{$Think.lang.refund_request}</div>

<table class="uk-table">
	<tr><td width=120>退款金额({$order_currency})</td>
	<td><input type="text" name="amount"  required min="1.00" max="{$order_amount}" value="{$order_amount}"/></td>
</tr>
  </table>
        <div class="uk-modal-footer uk-text-right">
		<button class="uk-button uk-button-danger" type="submit">{$Think.lang.confirm}</button>
		</div>
	</form>
</div>

</div>

<!-- Modal 拒付 -->
<div class="uk-modal" id="cbModal">
    <form id="validate_form1" action="__CONTROLLER__/processOrder" class="uk-form" method="get" >
	<input type="hidden" name="oid" value="{$order_id}"/>
	<input type="hidden" name="order_status" value="9"/>
	<div class="uk-modal-dialog"> <a class="uk-modal-close uk-close"></a>
        <div class="uk-modal-header">交易拒付</div>

<table class="uk-table">
	<tr><td width=120>拒付金额({$order_currency})</td>
	<td><input type="text" name="amount"  required min="0" max="{$order_amount}" value="{$order_amount}"/></td>
</tr>
  </table>
        <div class="uk-modal-footer uk-text-right">
		<button class="uk-button uk-button-danger" type="submit">{$Think.lang.confirm}</button>
		</div>
	</form>
</div>

</div>


